<?php
namespace app\index\controller;

use think\Db;
class Lbt{
	public function queryAll(){
		$lbt = Db::query('select * from lbt');
		return json(["code"=>200,"data"=>$lbt]);
	} 
	public function add(){
		$url = input('post.url');
		$to = input('post.to');
		try{
			$res = Db::execute('insert into gerenwangzhan.lbt (id,url,`to`) values (null,?,?)',[$url,$to]);
			return json(["code"=>200,"msg"=>'操作成功']);
		}catch(e){
			return json(["code"=>500,"msg"=>'操作失败']);
		}
	} 
	public function delete(){
		$id=input('get.id');
		try{
			$res=Db::execute('delete from lbt where id=?',[$id]);
			return json(["code"=>200,"msg"=>'操作成功']);
		}catch(e){
			return json(["code"=>500,"msg"=>'操作失败']);
		}
	}
	public function update(){
		$url = input('post.url');
		$to = input('post.to');
		$id = input('post.id');
		try{
			$res=Db::execute('update lbt set url=?,to=? where id=?',[$url,$to,$id]);
			return json(["code"=>200,"msg"=>'操作成功']);
		}catch(e){
			return json(["code"=>500,"msg"=>'操作失败']);
		}
	}
}